import request from '@/utils/request.js'

/**
 * 获取Playlist列表
 */
export const getPlaylistPage = (params) =>
  request.get('/playlist/page', { params })

/**
 * 获取Playlist的歌曲列表
 */
export const getPlaylistSongs = (id, name) =>
  request.get(`/playlist/get/songs/${id}`, {
    params: {
      name
    }
  })

/**
 * 获取歌单可用的歌曲
 */
export const getPlaylistAvailableSongs = (name) =>
  request.get(`/playlist/available/songs`, { params: { name } })

/**
 * 保存或更新Playlist
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const saveOrUpdatePlaylist = (data) => request.post('/playlist', data)

/**
 * 批量删除Playlist
 * @param ids
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const deleteBatchPlaylist = (ids) =>
  request.delete('/playlist/del/batch', { data: ids })

/**
 * 添加歌曲到歌单
 * @param data : {
 *  id:number 歌单id
 *  songIds:Arrays<number> 歌曲id集合
 * }
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const addPlaylistSongs = (data) =>
  request.post('/playlist/add/songs', data)

/**
 * 删除歌曲从歌单
 * @param data : {
 *  id:number 歌单id
 *  songIds:Arrays<number> 歌曲id集合
 * }
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const deletePlaylistSongs = (data) =>
  request.post('/playlist/remove/songs', data)
